/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  浮层广告
 * @author  wangxin | xinwang200110@sohu-inc.com
 * @version 1.0 | 2012-11-22
 * @param
 * @example
 * adLayer({
 * 		buttonl: element  //触发浮层的按钮
 * 		url: string //广告的链接地址
 * })
 */
define(function(require, exports, module){
    var _temp = require('../../common/mod/modTemplate').modTemplate;
    var tpl = '<div class="ad-mod" style="display:none;z-index:9999" id="adLayer"><div class="con"><a target="_blank" href="#{link}" target="_blank"><img src="#{url}" style="width:320px;height:320px;"></a></div></div>';
    return function(o){
    
        //将广告层隐藏在Body最后，待用
        var ele = o.button, x, y;
        $('body').append(_temp(tpl, {
            url: o.url || '',
            link: o.link || ''
        }));
        var layer = $('#adLayer');
        //绑定事件
        ele.on('mouseover', function(){
            x = ele.offset().left + ele.width() - layer.width();
            y = ele.offset().top;
            layer.css({
                top: y,
                left: x,
                position: 'absolute'
            });
            layer.show();
        });
        layer.on('mouseout', function(){
            layer.hide();
        });
    }
});
